"""
This classes are the different available extras, like Shield, etc...
$Id: extras.py,v 1.3 2004/12/17 09:57:49 krawczyk Exp $
"""

import pygame, colorsys
from pygame.locals import *
import config, flocke

extralist = []

class Extra(flocke.Tumbling_Mover):
    """
    Basis Class for diverse Extras the player can get.
    """

    config = config.extras
    
    def __init__(self, group):
        self.font = self.config["font"]
        self.color_h = 0
        flocke.Tumbling_Mover.__init__(self, group)

    def _Create(self):
        self.image = self._CreateImg()
        self.rect = self.image.get_rect()
        
    def _CreateImg(self):
        r,g,b = colorsys.hsv_to_rgb(self.color_h, .91, .81)
        return self.font.render(self.Type(), 0, (r*255, g*255, b*255))

    def _Screen_left(self):
        self.kill()

    def update(self):
        self.color_h += 0.9/60
        if self.color_h > 1.0: self.color_h = 0
        self._Create()
        flocke.Tumbling_Mover.update(self)

    def Type(self):
        raise NotImplementedError

    def Still_Image(self, gdata):
        img = pygame.Surface(self.image.get_size())
        #img.fill((0, 0, 0, 255))
        img.set_colorkey( (0, 0, 0) )
        tb = self.font.render(self.Type(), 0, (1,1,1))
        tw = self.font.render(self.Type(), 0, (255, 255, 205))
        img.blit(tb, (-1,-1))
        img.blit(tb, (1,-1))
        img.blit(tb, (-1,1))
        img.blit(tb, (1,1))
        img.blit(tw, (0,0))
        self.image = img
        self.rect = img.get_rect()

class Extra_Multiple_Ball(Extra):
    def __init__(self, group):
        Extra.__init__(self, group)

    def Type(self):
        return "3"

class Extra_Double_Ball(Extra):
    def __init__(self, group):
        Extra.__init__(self, group)

    def Type(self):
        return "2"

class Extra_Life(Extra):
    def __init__(self, group):
        Extra.__init__(self, group)

    def Type(self):
        return "L"

class Extra_Snow(Extra):
    snow_percent = config.extras["extra_snow.percentage"]
    
    def __init__(self, group):
        Extra.__init__(self, group)

    def Snow_percentage(self):
        return self.snow_percent

    def Type(self):
        return "S"

class Extra_slow_Snowball(Extra):
    def __init__(self, group):
        Extra.__init__(self, group)

    def Type(self):
        return "z"

class Extra_tumbling_Snowball(Extra):
    def __init__(self, group):
        Extra.__init__(self, group)

    def Type(self):
        return "T"

def Init():
    global extralist
    extralist = [ Extra_Double_Ball, Extra_Multiple_Ball, Extra_Life, Extra_Snow, Extra_slow_Snowball, Extra_tumbling_Snowball ]
    config.Status_top("Initialising Extras...")
